<template>
    <page-meta :page-style="$theme.pageStyle">
        <!-- #ifndef H5 -->
        <navigation-bar :front-color="$theme.navColor" :background-color="$theme.navBgColor" />
        <!-- #endif -->
    </page-meta>
    <u-sticky h5-nav-height="0" bg-color="transparent">
        <u-navbar :is-back="false" :is-fixed="false" title="创作中心" :border-bottom="false" :title-bold="true"
            :title-color="$theme.navColor" :background="{ background: $theme.navBgColor }">
        </u-navbar>
    </u-sticky>
    <view class="">
        <image class="logo" src="/static/images/logo.png" mode="widthFix"></image>
        <view class="container">
            <view class="item" v-for="(item, index) in items" :key="index" @click="handleItemClick(item)">
                <image :src="item.image" class="item-image" mode="aspectFit"></image>
                <view class="text-container">
                    <text class="item-title">{{ item.title }}</text>
                    <text class="item-description">{{ item.description }}</text>
                </view>
            </view>
        </view>
    </view>
    <tabbar />
</template>

<script lang="ts" setup>
import { ref, reactive, computed } from 'vue'
import { onLoad, onShow, onReady } from '@dcloudio/uni-app'

const items = ref([
    {
        image: '/static/images/image.png', // 替换为实际图片链接
        title: '图片素材',
        description: '图片大小及样式'
    },
    {
        image: '/static/images/video.png', // 替换为实际图片链接
        title: '视频素材',
        description: '描述内容2'
    },
    {
        image: '/static/images/audio.png', // 替换为实际图片链接
        title: '音频素材',
        description: '描述内容2'
    },
    {
        image: '/static/images/imageCopy.png', // 替换为实际图片链接
        title: '文案素材',
        description: '描述内容2'
    },
    {
        image: '/static/images/ai-1.png', // 替换为实际图片链接
        title: '创作空间',
        description: '描述内容2'
    },
    {
        image: '/static/images/videos-1.png', // 替换为实际图片链接
        title: '视频管理',
        description: '描述内容2'
    },
    {
        image: '/static/images/images-1.png', // 替换为实际图片链接
        title: '图文管理',
        description: '描述内容2'
    }
    // 可以继续添加更多项
])

const handleItemClick = (item) => {
    uni.showToast({ title: `进入${item.title}`, icon: 'none' });
}

// 根页面样式
const pageStyle = computed(() => {
    const { bg_type, bg_color, bg_image } = state.meta[0]?.content ?? {}
    if (bg_type != undefined) {
        return bg_type == 1 ? { 'background-color': bg_color } : { 'background-image': `url(${bg_image})` };
    } else {
        return ""
    }
})

</script>

<style lang="scss" scoped>
.content {
    //background: linear-gradient(45deg, #f0f4f7 0%, #FFE0B2 100%);
    min-height: 100vh;
    padding: 40rpx 20rpx;
}

.logo {
    width: 80%;
    height: 250rpx;
    margin: 30rpx auto;
    display: block;
    filter: drop-shadow(0 8rpx 20rpx rgba(255, 152, 0, 0.1));
}

.container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40rpx;
    padding: 0 20rpx;
}

.item {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 24rpx;
    padding: 30rpx;
    box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.08);
    backdrop-filter: blur(10rpx);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1rpx solid #FFE0B2;
    position: relative;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 8rpx;
        background: linear-gradient(90deg, #FFB74D 0%, #FF9800 100%);
    }

    &:active {
        transform: scale(0.98);
        box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.15);
    }

    .item-image {
        width: 120rpx;
        height: 120rpx;
        margin: 0 auto 30rpx;
        padding: 20rpx;
        background: #FFF3E0;
        border-radius: 50%;
        filter: hue-rotate(-20deg) saturate(1.2);
    }

    .item-title {
        font-size: 32rpx;
        color: #EF6C00;
        font-weight: 600;
        text-align: center;
        margin-bottom: 20rpx;
        letter-spacing: 1rpx;
    }

    .item-description {
        font-size: 26rpx;
        color: #8D6E63;
        line-height: 1.5;
        text-align: center;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        padding: 0 20rpx;
    }
}
</style>
